<?php
namespace app;

use think\facade\Db;

class Logined extends Basic
{
    public $user_id = null;
    public $user_info = null;
    function initialize()
    {
        parent::initialize();
        $token= $this->request->header('token');
        if(!$token){
            throw new \think\exception\HttpException(200, '请登录！');
        }
        $token = Db::name('token')->where('token',$token)->find();
        if(!$token){
            throw new \think\exception\HttpException(200, '登录状态已失效！');
        }
        $this->user_id=$token['token_user_id'];
        $this->user_info=Db::name('user')->where('user_id',$this->user_id)->find();
    }



}
